# x = 2
# y = 2
# if ( x == y ):
#     print("Equal")
# else:
#     print("Not Equal")
#
# k = 0
# while True:
#     s = input("请输入 q 退出:")
#     if s == 'q':
#         k += 1
#         continue
#     else:
#         k += 2
#     break
# print(k)
import shutil

# for n in range(400, 500):
#     i = n // 100
#     j = n // 10 % 10
#     k = n % 10
#     if n == i**3+j**3 + k ** 3:
#         print(n)

# w = input("请输入数字和字母构成的字符串:")
# for x in w:
#     if'0'<= x <='9':
#         continue
#     else:
#         w.replace(x, '')
# print(w)

# for i in range(3):
#     for s in "abcd":
#         if s == "c":
#             break
#         print(s, end="")

# for i in range(10):
#     if i % 2 == 0:
#         continue
#     else:
#         print(i, end=",")

# vlist = list(range(5))
# print(vlist)

# s = ''
# try:
#     for i in range(1, 10, 2):
#         s.append(i)
# except:
#     print('error')
# print(s)

# txt_path = 'D:\\some.txt'
# f = open('D:/some.txt', 'r')
# lines = f.readlines()
# for line in lines:
#     print(line)
# f.close()

# shutil.copy(r'D:/some.txt', r'C:/data')

# import os
#
# # 获取当前工作目录
# current_directory = os.getcwd()
# print("当前工作目录:", current_directory)
#
# # 获取当前目录下的所有内容
# all_contents = os.listdir(current_directory)
# print("当前目录下的所有内容:")
# for content in all_contents:
#     print(content)

# import csv
# # 要写入的数据
# data = [
#     ['A', '1', '2', '3'],
#     ['B', '4', '5', '6'],
#     ['C', '7', '8', '9']
# ]
# # 写入CSV文件
# with open('sec.csv', 'w', newline='') as csvfile:
#     writer = csv.writer(csvfile)
#     for row in data:
#         writer.writerow(row)
# print("数据已成功写入到 sec.csv 文件中。")
# # 读取CSV文件
# with open('sec.csv', 'r', newline='') as csvfile:
#     reader = csv.reader(csvfile)
#     # 逐行读取数据并打印
#     for row in reader:
#         print(row)

# import math
# import cmath
#
# def safe_sqrt(x):
#     if isinstance(x, complex):
#         return cmath.sqrt(x)
#     else:
#         return math.sqrt(x)
#
# # 测试
# print(safe_sqrt(4))       # 输出: 2.0
# print(safe_sqrt(-4))      # 输出: 2j
# print(safe_sqrt(4+3j))    # 输出: (2.0493901531919194+0.4642398995689606j)

# import cmath
#
# def safe_sqrt(x):
#     return cmath.sqrt(x)
#
# # 测试
# print(safe_sqrt(4))       # 输出: (2+0j)
# print(safe_sqrt(-4))      # 输出: 2j
# print(safe_sqrt(4+3j))    # 输出: (2.1213203435596424+0.7071067811865476j)

# import math
# import cmath
#
# def safe_sqrt(x):
#     if isinstance(x, complex):
#         return cmath.sqrt(x)
#     else:
#         return math.sqrt(x)
#
# # 测试
# print(safe_sqrt(4))       # 输出: 2.0
# print(safe_sqrt(-4))      # 输出: 2j
# print(safe_sqrt(4+3j))    # 输出: (2.1213203435596424+0.7071067811865476j)

# import math
# import cmath
#
# def safe_sqrt(x):
#     if x >= 0:
#         return math.sqrt(x)
#     else:
#         return cmath.sqrt(x)
#
# # 测试
# print(safe_sqrt(4))    # 输出: 2.0
# print(safe_sqrt(-4))   # 输出: 2j

# try:
#     # 打开文件以写入模式
#     with open('text.txt', 'w') as file:
#         while True:
#             # 读取用户输入
#             user_input = input("请输入字符串（输入E结束）：")
#
#             # 检查是否输入了 E，如果是则结束循环
#             if user_input.upper() == 'E':
#                 break
#
#             # 写入用户输入到文件
#             file.write(user_input + '\n')
#
# except KeyboardInterrupt:
#     print("\n程序已终止")
#
# except Exception as e:
#     print("发生错误:", e)
#
# finally:
#     # 确保文件关闭
#     file.close()
